#!/usr/bin/env python
# coding=UTF-8
'''
@autoAdd: true
@Author: hutong
@LastEditors: hutong
@Date: 2019-05-10 23:37:30
@LastEditTime: 2019-05-12 17:10:31
'''

import sys
import os
import re




perf_path = sys.argv[1]
date_list = []

for perf_filename in os.listdir(perf_path):
    if os.path.isfile(perf_path + perf_filename):
        if "VIRTUAL_VOLUMES_PERPETUAL_MONITOR.log" in perf_filename:
            # print(perf_path + perf_filename)
            with open(perf_path + perf_filename) as PERF_FILE:
                for i in PERF_FILE:
                    head_data = re.findall(
                    r"(\d{4}-\d{1,2}-\d{1,2}\s\d{1,2}:\d{1,2}:\d{1,2})", i)
                    if head_data :
                        head_data_line = head_data[0]
                        date_list.append(head_data_line)


date_list.sort()
begin_date = date_list[0]
date_list.sort(reverse=True)
end_date = date_list[0]
print("Perf File From %s To %s" % (begin_date,end_date))